package com.example.cloud.service;

import org.springframework.stereotype.Service;

import com.example.cloud.config.GrpcClient;

import io.grpc.Channel;

@Service
public class GreetClient {

    @GrpcClient("grpc-service")
    private Channel channel;

    public String greet() {
        GreeterGrpc.GreeterBlockingStub stub = GreeterGrpc.newBlockingStub(channel);
        HelloRequest request = HelloRequest.newBuilder().setName("小仝").build();
        HelloReply reply = stub.sayHello(request);
        System.out.println("--------" + reply.getMessage());
        return reply.getMessage();
    }

}
